import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class TExecutor {

    public static ExecutorService executor = new ThreadPoolExecutor(3, Runtime.getRuntime().availableProcessors() - 1,
            50L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>(50));


    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            submit(i);
        }
    }

    private static void submit(int index) {
        executor.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(new Date().toLocaleString() + ", index:" + index + ", thread:" + Thread.currentThread());
            }
        });
    }
}
